﻿using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using GMusicBox.Core;

namespace GMusicBox
{
    public class ListView : System.Windows.Forms.ListView
    {
        private bool elv;

        [System.ComponentModel.DefaultValue(true)]
        public bool NeverShowHScrollBar { get; set; }

        protected override void WndProc(ref Message m)
        {
            if ((m.Msg == 15) && !this.elv)
            {
                if (Environment.OSVersion.Version.Major >= 6 && !this.DesignMode)
                {
                    this.Font = new Font("微软雅黑", 9f);
                }
                NativeMethods.SetWindowTheme(base.Handle, "explorer", null);
                this.elv = true;
            }

            if (this.View == View.Details && NeverShowHScrollBar)
                NativeMethods.ShowScrollBar(this.Handle, 0, 0);

            base.WndProc(ref m);
        }
    }
}
